﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain.Editor;

namespace Brain
{
    public class LanguageFile : IBrainSerialiable
    {
        public void DeserializedAll()
        {
        }
        public Dictionary<string, string> Strings;

        public LanguageFile()
        {
            Strings = new Dictionary<string, string>();
        }

        public SerializationData Data { get; set; }

        public void SerializeData(DefaultSerializationManager manager)
        {
            Data = new SerializationData();

            int index = 0;
            Data.AddData("Language.Values", Strings.Count);
            foreach (KeyValuePair<string, string> value in Strings)
            {
                Data.AddData("Language.Key" + index, value.Key);
                Data.AddData("Language.Value" + index, value.Value);
                index++;
            }
        }

        public void DeserializeData(DefaultSerializationManager manager, SerializationData newData)
        {
            int count = newData.GetData<int>("Language.Values");
            for (int i = 0; i < count; i++)
            {
                string key = newData.GetData<string>("Language.Key" + i);
                string value = newData.GetData<string>("Language.Value" + i);
                Strings.Add(key, value);
            }
        }
    }
}
